<template>
  <view class="u-page">
    <UserHeader @loginout="loginOut" @login="login"></UserHeader>
    <u-gap height="10"></u-gap>
    <Worker v-if="roles.indexOf('worker') > -1"></Worker>
  </view>
</template>

<script>
const log = console.log.bind(console)
import { mapActions, mapGetters } from 'vuex'
import userHeader from './userHeader.vue'
import Worker from './worker.vue'
export default {
  components: {
    UserHeader: userHeader,
    Worker: Worker,
  },
  data() {
    return {}
  },
  watch: {},
  onLoad() {
    this.$now()
  },
  mounted() {},
  computed: {
    ...mapGetters(['userName', 'roles']),
  },
  methods: {
    loginOut() {
      this.$confirm('确定要退出登录吗？')
        .then((res) => this.$store.dispatch('user/logOut'))
        .catch((err) => {})
    },
    login() {
      this.$login()
    },
  },
}
</script>

<style lang="scss"></style>
